<template>
	<div class="mainWrapper Adjustment">
		<el-breadcrumb separator="/">
			<el-breadcrumb-item :to="{ path: '/' }">
				<i class="lh lh-caiwu fw_100"></i>
			</el-breadcrumb-item>
			<el-breadcrumb-item>账单结算</el-breadcrumb-item>
			<el-breadcrumb-item>人才调账明细</el-breadcrumb-item>
		</el-breadcrumb>

		<div class="content_Box box-shadow">
			<div class="py_5 px_10">
				<el-row>
					<el-col :span="3">
						<el-button type="default" class="fl" @click="downloadOrder()" round size="mini">导出</el-button>
					</el-col>
					<el-col :span="21" class="fr">
						<el-form :inline="true" class="form-inline fr" @keyup.enter.native="shearchBtn()">
							<el-form-item>
								<el-input v-model="adjustment_sn" placeholder="调账记录编号"></el-input>
							</el-form-item>
							<lh-agent-list @sendValue="setValue" :reset="agent_reset"></lh-agent-list>
							<el-form-item>
								<el-select class="w_110" v-model="city_val" placeholder="请选择城市" @change="changeCity">
									<el-option
										v-for="item in cityList"
										:key="item.id"
										:label="item.name"
										:value="`${item.id}|${item.name}`"
									></el-option>
								</el-select>
							</el-form-item>
							<el-form-item>
								<el-select v-model="s_area_arr" multiple collapse-tags placeholder="商圈">
									<el-button
										size="mini"
										type="primary"
										class="round-right all-area"
										@click="selectAllArea()"
										native-type="button"
										>{{ areaStatus ? '全选' : '取消全选' }}</el-button
									>
									<el-option
										v-for="item in areaList"
										:key="item.id"
										:label="item.area_name"
										:value="`${item.id}|${item.area_name}`"
									></el-option>
								</el-select>
							</el-form-item>
							<!-- <el-form-item class="w_150">
								<el-autocomplete
									class="inline-input"
									v-model="business_name"
									:fetch-suggestions="querySearch3"
									placeholder="请选择商户"
									:trigger-on-focus="true"
									@select="handleSelect3"
									clearable
									@clear="selectClear('business_name')"
								></el-autocomplete>
							</el-form-item> -->
							<el-form-item>
								<el-autocomplete
									size="mini"
									class="w_150"
									v-model="shop_name"
									:fetch-suggestions="querySearch"
									placeholder="请选择店铺"
									:trigger-on-focus="true"
									@select="handleSelect"
									clearable
									@clear="selectClear('shop_name')"
								></el-autocomplete>
							</el-form-item>
							<el-form-item>
								<el-autocomplete
									size="mini"
									class="w_130"
									v-model="s_personnel_name"
									:fetch-suggestions="querySearchStaff"
									placeholder="接单人"
									:trigger-on-focus="true"
									@select="handleSelectStaff"
									clearable
									@clear="selectClear('s_personnel_name')"
								></el-autocomplete>
							</el-form-item>
							<el-form-item class="w_90">
								<el-select v-model="adjust_type" placeholder="调账类型" clearable @clear="selectClear('adjust_type')">
									<el-option label="商户调账" value=""></el-option>
									<!-- <el-option label="平台调账" value="shop"></el-option> -->
								</el-select>
							</el-form-item>
							<el-form-item class="w_90">
								<el-select v-model="adjust_label" placeholder="费用类别" clearable @clear="selectClear('adjust_label')">
									<el-option
										v-for="item in TypeArr"
										:key="item.id"
										:label="item.label_name"
										:value="item.id"
									></el-option>
								</el-select>
							</el-form-item>
							<el-form-item class="w_90">
								<el-select v-model="status" placeholder="状态" clearable @clear="selectClear('status')">
									<el-option
										v-for="item in statusObj"
										:key="item.value"
										:label="item.label"
										:value="item.value"
									></el-option>
								</el-select>
							</el-form-item>
							<el-form-item prop="datetime1">
								<el-form-item prop="date1">
									<el-date-picker
										class="w_180i"
										v-model="start_time"
										type="datetime"
										value-format="yyyy-MM-dd HH:mm:ss"
										format="yyyy-MM-dd HH:mm:ss"
										default-time="00:00:00"
										placeholder="创建开始时间"
									>
									</el-date-picker>
								</el-form-item>
							</el-form-item>
							~
							<el-form-item prop="datetime2">
								<el-form-item prop="date2">
									<el-date-picker
										class="w_180i round-right"
										v-model="end_time"
										type="datetime"
										value-format="yyyy-MM-dd HH:mm:ss"
										format="yyyy-MM-dd HH:mm:ss"
										default-time="23:59:59"
										placeholder="创建结束时间"
									>
									</el-date-picker>
								</el-form-item>
							</el-form-item>
							<el-button size="mini" type="primary" class="round-right" native-type="button" @click="shearchBtn"
								>搜索</el-button
							>
							<el-button size="mini" round @click="resetBtn">重置</el-button>
						</el-form>
					</el-col>
				</el-row>
			</div>

			<div class="tableMaxBox">
				<template>
					<!-- 表格部分 -->
					<el-table :data="adjustmentList" stripe>
						<el-table-column type="index" width="50" label="序号" align="center"></el-table-column>
						<el-table-column prop="sn" label="调账记录编号" width="120"></el-table-column>
						<el-table-column prop="business_name" label="商户名称" min-width="120"></el-table-column>
						<el-table-column prop="shop_name" label="店铺名称" min-width="120"></el-table-column>
						<el-table-column prop="agent_name" label="代理商" width="110"></el-table-column>
						<el-table-column prop="city_name" label="城市" width="110"></el-table-column>
						<el-table-column prop="area_name" label="商圈" min-width="80"></el-table-column>
						<el-table-column prop="staff_name" label="接单人" width="80"></el-table-column>
						<el-table-column prop="mobile" label="手机号" width="100"></el-table-column>
						<el-table-column prop="adjust_type" label="调账类型" align="center">
							<span class="text-success">商户调账</span>
							<!-- <template slot-scope="{ row }">
								<span class="text-success" v-if="row.adjust_type == 'staff'">商户调账</span>
								<span class="text-info" v-if="row.adjust_type == 'shop'">平台调账</span>
							</template> -->
						</el-table-column>
						<el-table-column prop="adjust_label_name" label="费用类别" align="center"></el-table-column>
						<el-table-column prop="adjust_amount" label="金额" width="70"></el-table-column>
						<el-table-column prop="remark" label="备注" min-width="120"></el-table-column>
						<el-table-column prop="status" label="状态" width="80">
							<template slot-scope="{ row }">
								<span class="text-light" v-if="row.status == 10">已创建</span>
								<span class="text-primary" v-if="row.status == 20">已入账单</span>
								<span class="text-danger" v-if="row.status == 30">已作废</span>
								<span class="text-info" v-if="row.status == 40">待支付</span>
								<span class="text-success" v-if="row.status == 50">已付款</span>
							</template>
						</el-table-column>
						<el-table-column prop="bill_sn" label="账单编号" width="120"></el-table-column>
						<el-table-column prop="order_record_sn" label="支付记录编号" width="120"></el-table-column>
						<el-table-column prop="adder" label="创建人" width="80"></el-table-column>
						<el-table-column prop="add_time" label="创建时间" width="160"></el-table-column>
						<el-table-column label="操作" min-width="100px" fixed="right">
							<template slot-scope="{ row }">
								<el-link :underline="false" class="InfoFont text-primary" @click="goTorecord(row)">操作记录</el-link>
							</template>
						</el-table-column>
					</el-table>
					<!-- 分页组件 -->
					<page :total="total" :pageNums="pageNum" :disableMountedFetch="true" @pagedata="onChildValue"></page>
				</template>
			</div>
		</div>

		<!-- 操作记录-弹框 -->
		<el-dialog
			:title="'操作记录：' + top_bill_sn"
			:visible.sync="cordTicket"
			width="600px"
			:close-on-click-modal="false"
		>
			<div class="auditCentent">
				<div class="timeline" v-if="message.add_time != '0000-00-00 00:00:00'">
					<el-button type="success" class="fl" round size="mini">已创建</el-button>
					<span>{{ message.add_time }}</span>
					<span>{{ message.adder }}</span>
				</div>
				<div class="timeline" v-if="message.affirm_time != '0000-00-00 00:00:00'">
					<el-button type="success" class="fl" round size="mini">已确认</el-button>
					<span>{{ message.affirm_time }}</span>
					<span>{{ message.affirm }}</span>
				</div>
				<div class="timeline" v-if="message.settlement_time != '0000-00-00 00:00:00'">
					<el-button type="success" class="fl" round size="mini">已入账单</el-button>
					<span>{{ message.settlement_time }}</span>
					<span>{{ message.settlementer }}</span>
				</div>
				<div class="timeline" v-if="message.payment_time != '0000-00-00 00:00:00'">
					<el-button type="success" class="fl" round size="mini">已支付</el-button>
					<span>{{ message.payment_time }}</span>
					<span>{{ message.paymenter }}</span>
				</div>
				<div class="timeline" v-if="message.invalid_time != '0000-00-00 00:00:00'">
					<el-button type="success" class="fl" round size="mini">已作废</el-button>
					<span>{{ message.invalid_time }}</span>
					<span>{{ message.invalider }}</span>
				</div>
			</div>
			<div slot="footer" class="dialog-footer">
				<span class="resetBtn" @click="hiddenRY()">关 闭</span>
			</div>
		</el-dialog>
	</div>
</template>

<script>
var common = require('../../../static/tool.js')
import { fetchBusinessForSearchList } from '@/api/shop.js'
export default {
	name: 'Billadjust',
	data() {
		return {
			url: common.url,
			head_url: common.head_url,
			sn: '',
			top_bill_sn: '',
			message: '',
			//搜索对应值
			adjustment_sn: '', //调账记录编号
			task_sn: '',
			bill_sn: '',
			statusDisabled: true,
			merchantsLists: [], // 商户列表

			area_arr: '', //商圈信息
			area_id: '',
			area_name: '',
			adjust_type: '', //账单类型
			status: '', //状态
			shop_id: '', //店铺id
			shop_sn: '', //店铺sn
			shop_name: '', //店铺名
			// business_sn: '', //商户名称
			// business_name: '',
			s_personnel_sn: '',
			s_personnel_name: '',
			start_time: '', //创建开始时间
			end_time: '', //创建结束时间
			cityList: [], //城市列表
			city_arr: '',
			city_id: '',
			city_name: '',
			adjust_label: '', //费用类别
			TypeArr: [], //费用类别数据
			statusObj: [
				{
					value: 10,
					label: '已创建'
				},
				{
					value: 20,
					label: '已入账单'
				},
				{
					value: 40,
					label: '待支付'
				},
				{
					value: 50,
					label: '已付款'
				},
				{
					value: 30,
					label: '已作废'
				}
			],

			adjustmentList: [], //调账列表
			renList: [], //人才列表
			//向分页组件传值
			total: 0,
			pageNum: 1,
			pageSizeNow: 20,
			areaList: [], //区域列表
			shopList: [], //店铺列表
			JobStateedit: false,
			JobStatesee: false,
			FPShowStop: false,
			cordTicket: false,
			AssignmentTips: false,

			//创建调账记录的值
			adjustment: {
				adjustment_sn: '', //调账记录编号
				task_sn: '', //任务编号
				dpmc: '', //店铺名称
				sq: '', //商圈
				gw: '', //岗位
				gzsj: '', //工作时间
				dj: '', //单价
				personnel_dj: '',
				jdr: '', //接单人
				sjsc: '', //实际时长
				fy: '', //费用
				qdsj: '', //签到时间
				wcsj: '', //完成时间
				zt: '', //状态
				sc: '1', //时长
				sc_next: '0',
				scje: '0', //时长金额
				qtje: '1', //其他金额
				qtje_next: '0',
				hjje: '0', //合计金额
				bz: '', //备注
				adjust_type: ''
			},
			cityList: [], //城市列表
			city_arr: '',
			city_id: '',
			city_name: '',
			city_val: '',
			areaList: [], //区域列表
			s_area_arr: '', //商圈信息
			s_area_id: '',
			s_area_name: '',
			areaStatus: true,
			agent_id: 0,
			agent_reset: 0
		}
	},
	computed: {
		//时长金额计算
		scje() {
			if (this.adjustment.adjust_type == 'shop') {
				if (this.adjustment.sc == 1) {
					return (
						Number(this.adjustment.sc_next) *
						Number(this.adjustment.dj.substring(0, this.adjustment.dj.length - 4)) *
						1
					).toFixed(2)
				} else {
					return (
						Number(this.adjustment.sc_next) *
						Number(this.adjustment.dj.substring(0, this.adjustment.dj.length - 4)) *
						(-1).toFixed(2)
					)
				}
			} else {
				if (this.adjustment.sc == 1) {
					return (
						Number(this.adjustment.sc_next) *
						Number(this.adjustment.personnel_dj.substring(0, this.adjustment.personnel_dj.length - 4)) *
						1
					).toFixed(2)
				} else {
					return (
						Number(this.adjustment.sc_next) *
						Number(this.adjustment.personnel_dj.substring(0, this.adjustment.personnel_dj.length - 4)) *
						(-1).toFixed(2)
					)
				}
			}
		},
		//合计金额计算
		hjje() {
			if (this.adjustment.qtje == 1) {
				return (Number(this.adjustment.qtje_next * 1) + Number(this.adjustment.scje) * 1).toFixed(2)
			} else {
				return (Number(this.adjustment.qtje_next * -1) + Number(this.adjustment.scje) * 1).toFixed(2)
			}
		},
		city_value() {
			return this.city_val
		}
	},
	watch: {
		scje(newValue, oldValue) {
			if (!isNaN(newValue)) {
				this.adjustment.scje = newValue
			} else {
				this.adjustment.scje = 0
			}
		},
		hjje(newValue, oldValue) {
			if (!isNaN(newValue)) {
				this.adjustment.hjje = newValue
			} else {
				this.adjustment.hjje = 0
			}
		},
		adjust_type(newValue) {
			this.statusDisabled = false
			this.statusObj = [
				{
					value: 10,
					label: '已创建'
				},
				{
					value: 20,
					label: '已入账单'
				},
				{
					value: 40,
					label: '待支付'
				},
				{
					value: 50,
					label: '已付款'
				},
				{
					value: 30,
					label: '已作废'
				}
			]
		},
		//商圈改变
		areaList(newValue, oldValue) {
			this.listShop()
		}
	},
	created() {
		this.start_time = this.$moment().subtract('days', 7).format('YYYY-MM-DD') + ' 00:00:00'
		this.end_time = this.$moment().format('YYYY-MM-DD') + ' 23:59:59'
		if (this.$route.query.task_sn) {
			this.task_sn = this.$route.query.task_sn
		}

		if (this.$route.query.adjustment_sn) {
			this.adjustment_sn = this.$route.query.adjustment_sn
		}
		this.PersonnelList()

		this.selectedAreasMap = {}
		this.alljob_type() //获取费用类别
		// this.getMerchants() //获取商户列表
	},
	mounted() {},
	methods: {
		//清空已选选项处理
		selectClear(type) {
			switch (type) {
				case 'business_name': //商户
					this.business_sn = ''
					break
				case 'shop_name': //商铺
					this.shop_sn = ''
					break
				case 's_personnel_name': //接单人
					this.s_personnel_name = ''
					break
				case 'adjust_type': //调账类型
					this.adjust_type = ''
					break
				case 'adjust_label': //费用类别
					this.adjust_label = ''
					break
				default:
					break
			}
		},
		//获取商户列表
		// async getMerchants() {
		// 	try {
		// 		let ret = await fetchBusinessForSearchList()
		// 		ret.list.forEach(item => {
		// 			item.value = item.name
		// 		})
		// 		this.merchantsLists = ret.list
		// 	} catch (err) {
		// 		console.log(err)
		// 	}
		// },
		//商户的自动完成
		// querySearch3(queryString, cb) {
		// 	var restaurants = this.merchantsLists
		// 	var results = queryString ? restaurants.filter(this.createFilter3(queryString)) : restaurants
		// 	// 调用 callback 返回建议列表的数据
		// 	cb(results)
		// },
		// createFilter3(queryString) {
		// 	return restaurant => {
		// 		return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
		// 	}
		// },
		// handleSelect3(item) {
		// 	this.business_name = item.name
		// 	this.business_sn = item.business_sn
		// },
		//获取商铺列表
		listUser() {
			let fn = new FormData()
			fn.append('sign_status', 30) //已合作的店铺
			fn.append('status', 1) //启用的店铺
			fn.append('city_id', this.city_id)
			fn.append('agent_id', this.agent_id)
			this.$http.post(this.url + '/shop/getListForSearch', fn).then(
				res => {
					if (res.data.msg == '查询成功' || res.data.code == '200') {
						if (res.data.data != null) {
							res.data.data.list.forEach(item => {
								item.value = item.name
							})
							this.shopList = res.data.data.list
						} else {
							this.shopList = []
						}
					} else if (res.data.code == '8886') {
						//code   8886  登录过期
						sessionStorage.clear()
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html'
							}
						})
						return
					} else {
						this.$message.error(res.data.msg)
						return
					}
				},
				res => {
					this.$message.error('网络错误！')
					return
				}
			)
		},
		//费用类别标签接口
		alljob_type() {
			let fn = new FormData()
			fn.append('label_type', 'bill_adjust_type')
			this.$http.post(this.url + '/label/list', fn).then(
				res => {
					if (res.data.msg == '查询成功' || res.data.code == '200') {
						this.TypeArr = res.data.data
					} else if (res.data.code == '8886') {
						//code   8886  登录过期
						sessionStorage.clear()
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html'
							}
						})
						return
					} else {
						this.$message.error(res.data.msg)
						return
					}
				},
				res => {
					this.$message.error('网络错误！')
					return
				}
			)
		},

		//人才调账明细列表
		listShop() {
			let s_departmentIds_Arr = new Array()
			this.s_area_arr.forEach(element => {
				let [id, name] = element.split('|') // es6 数组解构赋值
				s_departmentIds_Arr.push(id.toString())
			})

			let fn = new FormData()
			fn.append('pageSize', this.pageSizeNow) //条数
			fn.append('page', this.pageNum) //页数
			fn.append('sn', this.adjustment_sn) //调账记录编号
			fn.append('city_id', this.city_id) //城市Id
			fn.append('area_id', '' + s_departmentIds_Arr) //商圈Id
			// fn.append('business_sn', this.business_sn) //商户Id
			fn.append('shop_sn', this.shop_sn) //商铺Id
			fn.append('staff_name', this.s_personnel_name) //接单人姓名
			fn.append('adjust_type', this.adjust_type) //调账类型
			fn.append('adjust_label', this.adjust_label) //费用类别
			fn.append('status', this.status) //状态
			fn.append('agent_id', this.agent_id)

			if (this.start_time) {
				fn.append('start_time', this.start_time)
			} else {
				fn.append('start_time', '')
			} //开始时间
			if (this.end_time) {
				fn.append('end_time', this.end_time)
			} else {
				fn.append('end_time', '')
			} //结束时间

			this.$http.post(this.url + '/staffAdjust/getList', fn).then(
				res => {
					if (res.data.msg == '查询成功！' || res.data.code == '200') {
						if (res.data.data != null) {
							this.adjustmentList = res.data.data.list
							this.total = res.data.data.count
						} else {
							this.adjustmentList = []
							this.total = 0
						}
					} else if (res.data.code == '8886') {
						//code   8886  登录过期
						sessionStorage.clear()
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html'
							}
						})
						return
					} else {
						this.$message.error(res.data.msg)
						return
					}
				},
				res => {
					this.$message.error('网络错误！')
					return
				}
			)
		},
		PersonnelList() {
			//获取人才列表
			let fn = new FormData()
			// 展示已认证过的人员姓名
			fn.append('certification_status', 1) //实名认证状态 [1]已认证 [2]未认证
			this.$http.post(this.url + '/user/getListForSearch', fn).then(
				res => {
					if (res.data.msg == '查询成功' || res.data.code == '200') {
						if (res.data.data != null) {
							res.data.data.list.forEach(item => {
								item.value = item.name
							})
							this.renList = res.data.data.list
						} else {
							this.renList = []
						}
					} else if (res.data.code == '8886') {
						//code   8886  登录过期
						sessionStorage.clear()
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html'
							}
						})
						return
					} else {
						this.$message.error(res.data.msg)
						return
					}
				},
				res => {
					this.$message.error('网络错误！')
					return
				}
			)
		},
		// 监听城市val变化
		changeCity() {
			let [id, name, city_sn] = this.city_val.split('|') // es6 数组解构赋值
			this.city_id = id
			this.city_name = name
			this.city_sn = city_sn

			this.shop_name = ''
			this.shop_id = ''
			this.shop_sn = ''
			this.fetchAreaList() //商圈列表
			this.listUser() //店铺列表
		},
		//获取商圈列表
		fetchAreaList(city_id) {
			this.s_area_arr = []
			let fn = new FormData()
			fn.append('city_id', this.city_id)
			fn.append('agent_id', this.agent_id)
			this.$http.post(this.url + '/area/list', fn).then(
				res => {
					if (res.data.msg == '查询成功' || res.data.code == '200') {
						if (res.data.data != null) {
							res.data.data.list.forEach(item => {
								item.value = item.area_name
							})
							this.areaList = res.data.data.list
							// if (this.s_area_arr == '' || this.s_area_arr == null) {
							// 	// 默认选中非254-平谷的
							// 	this.areaList.forEach(element => {
							// 		// 平谷
							// 		if (element.area_name != '平谷') {
							// 			var pusharr = element.id + '|' + element.area_name
							// 			this.s_area_arr.push(pusharr)
							// 		}
							// 	})
							// }
							if (this.selectedAreasMap[`city-${city_id}`] && this.selectedAreasMap[`city-${city_id}`].length) {
								this.s_area_arr = this.selectedAreasMap[`city-${city_id}`]
							}
						} else {
							this.areaList = []
						}
					} else if (res.data.code == '8886') {
						//code   8886  登录过期
						sessionStorage.clear()
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html'
							}
						})
						return
					} else {
						this.$message.error(res.data.msg)
						return
					}
				},
				res => {
					this.$message.error('网络错误！')
					return
				}
			)
		},

		// 搜索按钮
		shearchBtn() {
			this.pageNum = 1
			this.listShop()
		},

		//重置按钮
		async resetBtn() {
			await this.resetData() //重置请求数据
			this.agent_reset += 1
		},

		// 操作记录
		goTorecord(row) {
			this.cordTicket = true
			this.top_bill_sn = row.bill_sn
			this.message = row //行数据
		},

		//重置请求数据
		async resetData() {
			this.pageNum = 1
			// this.city_arr = ''
			// this.city_id = ''
			// this.city_name = ''
			this.sn = ''
			this.adjustment_sn = ''
			this.task_sn = ''
			this.bill_sn = ''
			// this.area_arr = '' //商圈信息
			// this.area_id = ''
			// this.area_name = ''
			// this.business_sn = '' //商户编号
			// this.business_id = '' //所属商户ID
			// this.business_name = '' //所属商户name
			this.shop_id = '' //店铺id
			this.shop_sn = '' //店铺sn
			this.shop_name = '' //店铺名
			this.adjust_type = '' //账单类型
			this.adjust_label = '' //费用类别
			this.status = '' //账号状态： 1:正常  2:禁用
			this.s_personnel_name = ''
			this.s_personnel_sn = ''
			this.start_time = ''
			this.end_time = ''
			// this.listShop() //重新加载列表数据
		},
		//店铺的自动完成
		querySearch(queryString, cb) {
			var restaurants = this.shopList
			var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants
			// 调用 callback 返回建议列表的数据
			cb(results)
		},
		createFilter(queryString) {
			return restaurant => {
				return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
			}
		},
		handleSelect(item) {
			this.shop_id = item.id
			this.shop_sn = item.shop_sn
		},
		//店铺的自动完成
		querySearchStaff(queryString, cb) {
			var restaurants = this.renList
			var results = queryString ? restaurants.filter(this.createFilterStaff(queryString)) : restaurants
			// 调用 callback 返回建议列表的数据
			cb(results)
		},
		createFilterStaff(queryString) {
			return restaurant => {
				return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
			}
		},
		handleSelectStaff(item) {
			this.s_personnel_sn = item.staff_sn
		},

		//人才调账明细记录-导出
		downloadOrder() {

			let s_departmentIds_Arr = new Array()
			this.s_area_arr.forEach(element => {
				let [id, name] = element.split('|') // es6 数组解构赋值
				s_departmentIds_Arr.push(id.toString())
			})

			let obj = {
				token: JSON.parse(sessionStorage.getItem('manageInfo')).token,
				operation: 'export',
				export: 1,
				adjustment_sn: this.adjustment_sn, //调账记录编号
				city_id: this.city_id, //城市Id
				area_id: '' + s_departmentIds_Arr, //商圈Id
				// business_sn: this.business_sn,
				shop_sn: this.shop_sn,
				staff_name: this.s_personnel_name, //接单人姓名
				adjust_type: this.adjust_type, //调账类型
				adjust_label: this.adjust_label, //费用类别
				status: this.status, //状态
				start_time: this.start_time, //开始时间
				end_time: this.end_time, //结束时间
				agent_id: this.agent_id
			}

			let param = $.param(obj)
			window.location.href = this.url + '/staffAdjust/getList?' + param
		},
		//分页组件->子组件传值
		onChildValue(item) {
			this.pageNum = item[0]
			this.pageSizeNow = item[1]
			this.listShop()
		},
		changeBtndialogarea() {
			let [id, name] = this.area_arr.split('|') // es6 数组解构赋值
			this.area_id = id.toString()
			this.area_name = name.toString()
		},

		//关闭弹窗
		hiddenRY() {
			// this.JobState = false
			this.JobStateedit = false
			this.JobStatesee = false
			this.FPShowStop = false
			this.cordTicket = false
			this.AssignmentTips = false
			this.adjustment = {
				adjustment_sn: '', //调账记录编号
				task_sn: '', //任务编号
				dpmc: '', //店铺名称
				sq: '', //商圈
				gw: '', //岗位
				gzsj: '', //工作时间
				dj: '', //单价
				personnel_dj: '',
				jdr: '', //接单人
				sjsc: '', //实际时长
				fy: '', //费用
				qdsj: '', //签到时间
				wcsj: '', //完成时间
				zt: '', //状态
				sc: '1', //时长
				sc_next: '0',
				scje: '0', //时长金额
				qtje: '1', //其他金额
				qtje_next: '0',
				hjje: '0', //合计金额
				bz: '', //备注
				amout_staff: '', //人才单价
				adjust_type: '' //调账对象
			}
		},
		changeBtndialog() {
			let [id, name] = this.city_arr.split('|')
			this.city_id = id.toString()
			this.city_name = name.toString()
		},
		//全选-取消全选商圈
		selectAllArea() {
			let arr = []
			this.areaList.forEach(item => {
				arr.push(`${item.id}|${item.area_name}`)
			})
			if (this.areaStatus == true) {
				this.s_area_arr = arr
			} else {
				this.s_area_arr = []
			}
			this.areaStatus = !this.areaStatus
		},
		setValue(arrVal) {
			this.agent_id = arrVal.agent_id
			this.cityList = arrVal.city_list
			this.city_val = this.cityList[0].name
			this.city_id = this.cityList[0].id

			this.shop_name = ''
			this.shop_id = ''
			this.shop_sn = ''
			this.fetchAreaList() //商圈列表
			this.listUser() //店铺列表
		}
	},
	filters: {
		ReversalTime: function (value) {
			value = value % 24
			return common.getReversalTime(value)
		},
		dateshear: function (value) {
			value = value.substr(5, 5).trim()
			return value
		}
	}
}
</script>

<style scoped>
.auditCentent .labels {
	min-height: 100px;
}
.auditCentent .labels .labels_label {
	float: left;
	cursor: pointer;
}
.check_label {
	background: var(--purple4);
	color: #fff;
	border: none;
}
.pdf {
	width: 860px;
	height: 600px;
}
.main_user {
	background: var(--zfy-red);
	color: #fff;
	text-decoration: none;
	padding: 2px 4px;
	border-radius: 4px;
}

.auditCentent_next {
	display: flex;
	margin-bottom: 10px;
}

.timeline {
	height: 30px;
	line-height: 30px;
	margin-bottom: 20px;
}

.timeline span {
	margin-left: 10px;
}
</style>



// WEBPACK FOOTER //
// src/components/billshop/Billadjust.vue